package phasebook.client;

import javax.ejb.EJB;
import javax.ejb.Stateless;
import javax.jws.WebService;
import javax.servlet.annotation.WebServlet;

import lottery.msgs.LotteryResult;
import phasebook.client.msgs.MessageInfo;
import phasebook.client.msgs.MovementInfo;
import phasebook.client.msgs.PhotoInfo;
import phasebook.client.msgs.UserInfo;
import phasebook.client.msgs.UserProfileInfo;

@WebService(endpointInterface="phasebook.client.RemotePhasebookService")
@Stateless
public class PhasebookWebService implements RemotePhasebookService{
	@EJB LocalPhaseBookService service;
	
	// Retrieve Information 

	public UserInfo[] getFriends(long userId) {
		System.out.println("getFriends-WS: "+userId);
		return service.getFriends(userId);
	}
	
	public UserInfo[] getFriendRequests(long userId) {
		return service.getFriendRequests(userId);
	}
	
	public UserInfo[] getMyFriendRequests(long userId) {
		return service.getMyFriendRequests(userId);
	}
	
	public MovementInfo[] getFinancialMovements(long userId) {
		return service.getFinancialMovements(userId);
	}
	
	public MessageInfo[] getMessages(long myId,long userId) {
		return service.getMessages(myId, userId);
	}
		
	public UserProfileInfo getProfile(long userId) {
		return service.getProfile(userId);
	}
	
	public PhotoInfo[] getAlbum(long userId) {
		return service.getAlbum(userId);
	}
	
	public UserInfo[] findUsers(long userId,String regEx) throws Exception {
		return service.findUsers(userId, regEx);
	}
	
	public byte[] downloadPhoto(long photoId) {
		return service.downloadPhoto(photoId);
	}
	
	// Submit Information 
	
	public long registerUser(UserProfileInfo userProfile) throws Exception {
		return service.registerUser(userProfile);
	}
	
	public void updateUser(UserProfileInfo userProfile) throws Exception {
		service.updateUser(userProfile);
	}
	
	public long validateLogin(String userName, String password) throws Exception {
		System.out.println("login: "+userName);
		return service.validateLogin(userName, password);
	}
	
	public void publishMessage(MessageInfo newMessage) throws Exception {
		service.publishMessage(newMessage);
	}

	public void deleteMessage( long userId,  long messageId) throws Exception {
		service.deleteMessage(userId, messageId);
	}
	
	public void requestFriendship( long userId,  long friendId) throws Exception {
		service.requestFriendship(userId, friendId);
	}
	
	public void cancelFriendship( long userId, long friendId) throws Exception {
		service.cancelFriendship(userId, friendId);
	}
	
	public void cancelFriendshipRequest( long userId, long friendId) throws Exception {
		service.cancelFriendshipRequest(userId, friendId);
	}
	
	public void denyFriendshipRequest( long userId, long friendId) throws Exception {
		service.denyFriendshipRequest(userId, friendId);
	}
	
	public void acceptFriendshipRequest(long userId, long friendId) throws Exception {
		service.acceptFriendshipRequest(userId, friendId);
	}

	public void addPhoto( long userId, PhotoInfo photo, byte[] imageData) throws Exception {
		service.addPhoto(userId, photo, imageData);
	}
	
	public void placeBet( long userId, double amount, int result) throws Exception {
		service.placeBet(userId, amount, result);
	}
	
	public void updateBalance( long userId, double amount, long accountId) throws Exception {
		service.updateBalance(userId, amount, accountId);
	}
	
	public void createFinancialMovement( long userId, double amount, String description) throws Exception {
		service.createFinancialMovement(userId, amount, description);
	}
	
	public void processResults(LotteryResult[] lotteryResults) throws Exception {
		service.processResults(lotteryResults);
	}

	public void notifyLotteryParticipants(LotteryResult[] lotteryResults)	throws Exception {
		service.notifyLotteryParticipants(lotteryResults);
	}
}

